#include <bits/stdc++.h>
using namespace std;
using ll = long long;



void solve() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = a[0];
    ll sum = a[0];
    for(int i = 1; i < n; i++) {
        if(abs(a[i]) % 2 == abs(a[i - 1]) % 2) {
            sum = a[i];
        } else{
            if(sum < 0) {
                sum = a[i];
            } else{
                sum += a[i];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}